package logic

import (
	"context"
	"rent-ease/models/mysql"

	"rent-ease/honesrpc/honesrpc"
	"rent-ease/honesrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HonesDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHonesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HonesDetailLogic {
	return &HonesDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *HonesDetailLogic) HonesDetail(in *honesrpc.HonesDetailRequest) (*honesrpc.HonesDetailResponse, error) {
	// todo: add your logic here and delete this line
	var data mysql.Hones
	err := data.Honesdetail(mysql.DB, in.HonesId)
	if err != nil {
		return nil, err
	}

	return &honesrpc.HonesDetailResponse{
		Name:    data.Name,
		Address: data.Address,
		Phone:   int64(data.Phone),
		HonesId: in.HonesId,
	}, nil
}
